import {Color3, Scene} from '@babylonjs/core'
import {YkBabylonScene} from './create3D.ts'
import * as BABYLON from '@babylonjs/core'
import {
    BrickProceduralTexture, FireProceduralTexture,
    GrassProceduralTexture,
    MarbleProceduralTexture, RoadProceduralTexture, StarfieldProceduralTexture,
    WoodProceduralTexture
} from '@babylonjs/procedural-textures'

export const createMaterials = (ykScene: YkBabylonScene) => {
    console.log("创建场景材质")
    ykScene.marbleMaterial = new BABYLON.StandardMaterial('marbleMat')
    const marbleTexture = new MarbleProceduralTexture('marbleTex', 1024)
    marbleTexture.numberOfTilesWidth = 30
    marbleTexture.numberOfTilesHeight = 1000
    ykScene.marbleMaterial.diffuseTexture = marbleTexture
    ykScene.marbleMaterial.freeze()

    // 砖块材质
    ykScene.brickMaterial = new BABYLON.StandardMaterial('brick')
    const brickTexture = new BrickProceduralTexture('brickTexture', 4096)
    brickTexture.numberOfBricksWidth = 60
    brickTexture.numberOfBricksHeight = 100
    ykScene.brickMaterial.diffuseTexture = brickTexture
    ykScene.brickMaterial.freeze()

    ykScene.grassMaterial = new BABYLON.StandardMaterial('grass')
    const grassTexture = new GrassProceduralTexture('grassTexture', 4096)
    // grassTexture.grassColors = new Color3(134, 198, 118);
    ykScene.grassMaterial.diffuseTexture = grassTexture
    ykScene.grassMaterial.freeze()

    ykScene.woodMaterial = new BABYLON.StandardMaterial('wood')
    const woodTexture = new WoodProceduralTexture('woodTexture', 512)
    // woodTexture.woodColor =
    ykScene.woodMaterial.diffuseTexture = woodTexture
    ykScene.woodMaterial.freeze()

    ykScene.starFieldMaterial = new BABYLON.StandardMaterial('starFieldMaterial')
    ykScene.starFieldMaterial.diffuseTexture = new StarfieldProceduralTexture('starFieldMaterial', 512)
    ykScene.starFieldMaterial.freeze()

    ykScene.roadMaterial = new BABYLON.StandardMaterial('road')
    ykScene.roadMaterial.diffuseTexture = new RoadProceduralTexture('roadMaterial', 512)
    ykScene.roadMaterial.freeze()

    ykScene.fireMaterial = new BABYLON.StandardMaterial('fireMaterial')
    ykScene.fireMaterial.diffuseTexture = new FireProceduralTexture('fireMaterial', 512)
    ykScene.fireMaterial.freeze()

    // 添加不锈钢材质
    ykScene.steelMaterial = new BABYLON.StandardMaterial('steel')
    ykScene.steelMaterial.diffuseColor = new BABYLON.Color3(0.8, 0.8, 0.8)
    ykScene.steelMaterial.specularColor = new BABYLON.Color3(0.9, 0.9, 0.9)
    ykScene.steelMaterial.specularPower = 64
    ykScene.steelMaterial.roughness = 0.1
    ykScene.steelMaterial.freeze()

}